import Vue from 'vue';
import Router from 'vue-router';
// import HelloWorld from '@/components/HelloWorld';
import Login from '@/views/Login';
import Layout from '@/views/Layout';
import Dashboard from '@/views/Dashboard';

Vue.use(Router);
export const constantRoutes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/layout',
    name: 'Layout',
    component: Layout,
    children:[
      {
        path: '/',
        component: Dashboard
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/Error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/Error-page/401'),
    hidden: true
  }
];
// const layoutError = [
//   {
//     path: '*',
//     redirect: '/404',
//     hidden: true
//   }
// ];
const createRouter = () =>
  new Router({
    // mode: 'history',
    routes: constantRoutes
  });
const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}
export default router;
